package com.alpaca.recommend.config;

import com.alpaca.recommend.action.HelloController;
import com.alpaca.recommend.action.ItemController;
import com.alpaca.recommend.action.RecommendController;
import com.alpaca.recommend.action.TaskController;
import com.jfinal.config.*;
import com.jfinal.plugin.spring.SpringPlugin;
import org.ansj.util.MyStaticValue;

/**
 * Created by wangj on 2015/2/2.
 */
public class WebConfig extends JFinalConfig{
    @Override
    public void configConstant(Constants me) {
        me.setDevMode(true);
        me.setEncoding("UTF-8");
        initAnsjLibrary();
    }

    public static void initAnsjLibrary() {
        try {
            MyStaticValue.userLibrary = WebConfig.class.getResource("/library/default.dic").toURI().getPath();
            MyStaticValue.ambiguityLibrary = WebConfig.class.getResource("/library/ambiguity.dic").toURI().getPath();
        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void configRoute(Routes me) {
        me.add("/hello", HelloController.class);
        me.add("/recommend", RecommendController.class);
        me.add("/item", ItemController.class);
        me.add("/task", TaskController.class);
    }

    @Override
    public void configPlugin(Plugins me) {
        me.add(new SpringPlugin("classpath:application-context.xml"));
    }

    @Override
    public void configInterceptor(Interceptors me) {

    }

    @Override
    public void configHandler(Handlers me) {

    }
}
